package com.bdqn.demo.config;

import com.bdqn.demo.web.AuthorizationInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * InterceptorConfig
 *
 * @author f
 * @since 2021/11/30
 */
public class InterceptorConfig implements WebMvcConfigurer {
    /**
     * 配置拦截规则
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        String[] pathPatterns = {"/**"}; // 拦截路径规则
        String[] excludePathPatterns = {"/login", "/regist", "/statics/**"}; // 排除路径规则
        registry.addInterceptor(new AuthorizationInterceptor()) // 注册拦截器
                .addPathPatterns(pathPatterns) // 添加路径规则
                .excludePathPatterns(excludePathPatterns); // 添加排除路径规则
    }
}
